package com.wudl.core;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @version v1.0
 * @ProjectName Flinklearning
 * @ClassName TransformKeyBy
 * @Description TODO KeyBy
 * @Author wudl
 * @Date 2020/11/5 11:46
 */

public class TransformKeyBy {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<String> SourceDs = env.readTextFile("F:\\ideaWorkSpace2020\\jg\\Flinklearning\\wudl-flink-java\\input\\sensor-data.log");

        SourceDs.map(new MapFunction<String, String>() {
            @Override
            public String map(String value) throws Exception {
                String[] split = value.split(",");

                return split[0] + split[1];
            }
        }).keyBy(0).print();
        env.execute();

    }
}
